package com.gjy.spring.a03;

import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-11-16 09:41:00
 */
public class BeanTest {

    /**
     * 构造器的循环依赖是无法解决的:
     * Requested bean is currently in creation: Is there an unresolvable circular reference?
     * setter 可以解决循环依赖
     * 作用域为prototype无法解决循环依赖
     */
    @Test
    public void test2() {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("com.gjy.spring.a03");
        BeanA bean = context.getBean(BeanA.class);
        System.out.println(bean);
    }

    @Test
    public void test1() {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("com.gjy.spring.a03");
        BeanUse beanUse = context.getBean("beanUse", BeanUse.class);

        System.out.println(beanUse);
    }

}
